﻿@page "/ajaxs"
@inject IStringLocalizer<Ajaxs> Localizer

<h3>@Localizer["AjaxTitle"]</h3>

<h4>@Localizer["AjaxDescribe"]</h4>

<DemoBlock Introduction="@Localizer["NormalIntro"]" Title="@Localizer["NormalTitle"]" Name="Normal" Demo="typeof(Demos.Ajax.AjaxNormal)">
    <p>
        <b>@Localizer["NormalB"]</b>
        <div>@((MarkupString)Localizer["NormalDiv"].Value)</div>
    </p>
    <Pre>var option = new AjaxOption
{
    Url = "/api/Login",
    Data = new User() { UserName = "admin", Password = "1234567" }
};
var result = await AjaxService.InvokeAsync(option);</Pre>
</DemoBlock>

<DemoBlock Introduction="@Localizer["GotoIntro"]" Title="@Localizer["GotoTitle"]" Name="Goto" Demo="typeof(Demos.Ajax.AjaxGoto)" />

<MethodTable Items="@GetMethods()" />

@code
{
    /// <summary>
    /// 获得属性方法
    /// </summary>
    /// <returns></returns>
    private IEnumerable<MethodItem> GetMethods() => new MethodItem[]
    {
        new MethodItem()
        {
            Name = "InvokeAsync",
            Description = Localizer["InvokeAsync"],
            Parameters = "AjaxOption",
            ReturnValue = "string"
        },
        new MethodItem()
        {
            Name = "Goto",
            Description = Localizer["Goto"],
            Parameters = "string",
            ReturnValue = " — "
        }
    };
}
